package Resource;

import java.io.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class BufferedChar_01 {

    public static void main(String[] args) {
        try
        (
                BufferedReader br = new BufferedReader(new FileReader(""));
                BufferedWriter bw = new BufferedWriter(new FileWriter("src/test1.txt"));
        )
        {
            List<String> data = new ArrayList<>();
            String line;
            while((line=br.readLine())!=null){
                data.add(line);
            }
            System.out.println(data);
            List<String> sizes=new ArrayList<>();
            Collections.addAll(sizes,"一","二");
            Collections.sort(data, new Comparator<String>() {
                @Override
                public int compare(String o1, String o2) {
                    return  sizes.indexOf(o1.substring(0,o1.indexOf(".")))-
                            sizes.indexOf(o2.substring(0,o2.indexOf(".")));
                }
            });
            System.out.println(data);
//            data.forEach(s->{bw.write(s);bw.newLine();});
            for (String datum : data) {
                bw.write(datum);
                bw.newLine();
            }
            System.out.println(data);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
